<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   INQUIRY_JAVA
 - AUTHOR           :   Alex Cheung 
 - DATE CREATE      :   2006/02/03
 - DESCRIPTION      :   a PAGE-EDIT CONTENT JSP file for the function, INQUIRY_JAVA
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/02/03   Alex Cheung     1.0                 source is generated.
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page  import="com.erp.app.report.genericInquiry.InquiryJavaAction" %>
<%@ page  import="com.erp.app.report.genericInquiry.InquiryJavaRow" %>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="inquiryJavaForm" scope="session" type="com.erp.app.report.genericInquiry.InquiryJavaForm" />

<%
ArrayList inquiryJavaList = inquiryJavaForm.getMultiRows();
pageContext.setAttribute("inquiryJavaList", inquiryJavaList);
rowReadOnly = false;
TableSchema ts = inquiryJavaForm.getTs();
%>

<script language="javascript">

	function doLoad() {
		<%	if (CommonUtil.nullToString((String)session.getAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE)).equals(ProjectConstants.GENERIC_YES)) {
			session.removeAttribute(ProjectConstants.SESSION_ALERT_AFTER_SAVE);
			out.println("alert('Records saved.');");
		}
		String lastAction = (String) inquiryJavaForm.getPageEvent();
		if (lastAction != null) {
			if (lastAction.equalsIgnoreCase(InquiryJavaAction.ACTION_ADD_ATTACH) || lastAction.equalsIgnoreCase(InquiryJavaAction.ACTION_CHANGE_ATTACH)) {
				out.println(WebUtil.openUploadFileDo());
			}
		}%>
	}


	var tickVal = '0';
	var untickVal = '1';
	
	function doTick(cbName,idx) {
		var aInput = document.getElementsByName(cbName);
		if (aInput.length) {
			selectedObj = aInput[idx];
			if (aInput.length == 1)
				selectedObj = aInput[0];
		} else {
			selectedObj = aInput;
		}
		if (selectedObj.value != null && (selectedObj.value == tickVal || selectedObj.value == ""))
			selectedObj.value = untickVal;
		else
			selectedObj.value = tickVal;
	}
	
	function checkExclusive(cbNameTmp,cbName,idx) {
		doTick(cbName, idx);
		var obj = document.getElementsByName(cbNameTmp);
		var hiddenObj = document.getElementsByName(cbName);
		var objInqType = document.getElementsByName("inquiryType");
		if (obj.length) {
			cbObj = obj[idx];
			if (cbObj.checked) {
				var inqType = objInqType[idx].value;
				for (i=0; i<obj.length; i++) {
					if (objInqType[i].value == inqType) {
						obj[i].checked = 0;
						hiddenObj[i].value = "1";
					}
				}
				cbObj.checked = 1;
				hiddenObj[idx].value = "1";
			}
		}
	}

</script>

<body onLoad="javascript:doLoad();autofill_init();">
<html:form action="/inquiryJava">

<html:hidden property="pageEvent"/>
<html:hidden property="pageEventSrc"/>
<html:hidden property="pageMode"/>
<html:hidden property="deleteIdx"/>

<table class="table_top">

<tr>
	<td>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_EXIT%>"
			styleClass="button1"/>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_SEARCH%>"
			styleClass="button1"/>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_CLEAR%>"
			styleClass="button1"/>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_ADD_ROW%>"
			styleClass="button1"/>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_SAVE%>"
			styleClass="button1"/>
		<chtml:button form="inquiryJavaForm" pageEvent="<%=InquiryJavaAction.ACTION_REFRESH%>"
			styleClass="button1"/>
	</td>
</tr>

<tr>
	<td>

		<table class="table_crit">

		<tr class="col_label"> 
			<td class="col_label">&nbsp;</td>
			<td class="col_label_fr_to">
				<%
				webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_FROM");
				%>
				<%=webLabel%>
			</td>
			<td class="col_label_fr_to">
				<%
				webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_TO");
				%>
				<%=webLabel%>
			</td>
		</tr>
		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_INQUIRY_TYPE");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<html:text property="srchInquiryTypeFr" styleClass="textbox1" maxlength="<%=srchColSize%>" size="<%=srchDisplaySize%>"/>
			</td>
			<td class="col_value">
				<html:text property="srchInquiryTypeTo" styleClass="textbox1" maxlength="<%=srchColSize%>" size="<%=srchDisplaySize%>"/>
			</td>
		</tr>
		<tr>
			<%
			webLabel = ts.getDisplayWebLabelWithColonByObjectId("LBL_SRCH_CLASS_NAME");
			%>
			<td class="col_label">
			<%=webLabel%>
			</td>
			<td class="col_value">
				<html:text property="srchClassNameFr" styleClass="textbox1" maxlength="<%=srchColSize%>" size="<%=srchDisplaySize%>"/>
			</td>
			<td class="col_value">
				<html:text property="srchClassNameTo" styleClass="textbox1" maxlength="<%=srchColSize%>" size="<%=srchDisplaySize%>"/>
			</td>
		</tr>

		</table>

	</td>
</tr>

<tr>
	<td><font color='red'><html:errors/></font></td>
</tr>

<tr>
	<td class="grid_page">
	<%if(inquiryJavaForm.getTotalPage() == 0 ) { %>
		&nbsp;
	<%} else { %>
		<input type="button" value="Go" class="button1" onClick="javascript:doSubmit('<%=inquiryJavaForm.ACTION_SCROLL_TO%>');" >
		Page
		<html:text property="scrollTo" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="4" size="4" value="<%=String.valueOf(inquiryJavaForm.getCurrentPage())%>"/>
		of <%=inquiryJavaForm.getTotalPage()%>
	<%} %>
		<input type="button" value="|&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=inquiryJavaForm.ACTION_SCROLL_TO_FIRST_PAGE%>');" <%=inquiryJavaForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=inquiryJavaForm.ACTION_SCROLL_LEFT%>');" <%=inquiryJavaForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&gt;&gt;" class="button1" onClick="javascript:doSubmit('<%=inquiryJavaForm.ACTION_SCROLL_RIGHT%>');" <%=inquiryJavaForm.getSidx() < Integer.parseInt(inquiryJavaForm.getLastPageSidx()) ? "" : "disabled"%>>
		<input type="button" value="&gt;&gt|" class="button1" onClick="javascript:doSubmit('<%=inquiryJavaForm.ACTION_SCROLL_TO_LAST_PAGE%>');" <%=inquiryJavaForm.getSidx() < Integer.parseInt(inquiryJavaForm.getLastPageSidx()) ? "" : "disabled"%>>
	</td>
</tr>

</table>


<table class="table_grid">

	<tr class="grid_header">
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_DELETE");
		%>
		<td class="grid_header_col_narrow" nowrap>
			<%=webLabel%>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_INQUIRY_TYPE");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_CLASS_NAME");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_IS_MAIN_CLASS");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_JAVA_TYPE");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
		<%
			webLabel = ts.getDisplayWebLabelByObjectId("LBL_GRID_JAVA_SOURCE");
		%>
		<td class="grid_header_col" nowrap>
			<%=webLabel%>
		</td>
	</tr>

	<logic:iterate id="inquiryJavaRow" name="inquiryJavaList" indexId="idx" length="<%=String.valueOf(ProjectConstants.MAX_DISPLAY)%>" offset="<%=String.valueOf(inquiryJavaForm.getSidx())%>">

	<%
		InquiryJavaRow row = (InquiryJavaRow) inquiryJavaRow;
		boolean isDelete = !CommonUtil.isEmpty(row.getIsDelete());
	%>

	<% if(row != null) {%>

	<tr <%=(idx.intValue()%2 == 0)? "class='grid_result1'": "class='grid_result2'"%>>
		<td nowrap>
			<html:checkbox property="isDelete" name="inquiryJavaRow" value="<%= row.getIdx()%>" styleClass="checkbox1" disabled="<%=rowReadOnly%>" />
			<%--
			<input type=\"checkbox\" name=\"isDelete\" value=\"\" class=checkbox1 <%=rowReadOnly ? "disabled=\"true\"" : ""%> >
			--%>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_INQUIRY_TYPE"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_INQUIRY_TYPE"));
			%>
			<logic:equal name="inquiryJavaRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<html:text property="inquiryType" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getInquiryType())%>"/>
			</logic:equal>
			<logic:notEqual name="inquiryJavaRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<bean:write name="inquiryJavaRow" property="inquiryType" filter="true"/>
				<html:hidden property="inquiryType" value="<%=CommonUtil.nullToString(row.getInquiryType())%>"/>
			</logic:notEqual>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(ts.getColSizeByObjectId("LBL_GRID_CLASS_NAME"));
			displaySize = String.valueOf(ts.getDisplaySizeByObjectId("LBL_GRID_CLASS_NAME"));
			%>
			<logic:equal name="inquiryJavaRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<html:text property="className" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="<%=colSize%>" size="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getClassName())%>"/>
			</logic:equal>
			<logic:notEqual name="inquiryJavaRow" property="rowMode" value="<%=ProjectConstants.ROW_MODE_CREATE%>">
				<bean:write name="inquiryJavaRow" property="className" filter="true"/>
				<html:hidden property="className" value="<%=CommonUtil.nullToString(row.getClassName())%>"/>
			</logic:notEqual>
		</td>
		
		<td nowrap>
			<input type="checkbox" name="isMainClassTmp" <%= CommonUtil.nullToString(row.getIsMainClass()).equals("1")? "checked": "" %> onclick="javascript:checkExclusive('isMainClassTmp','isMainClass','<%=idx%>');" <%=(isDelete ? "disabled" : "")%>>
			<html:hidden property="isMainClass" value="<%= CommonUtil.nullToString(row.getIsMainClass()) %>" />
		</td>
		<td nowrap>
			<select name="javaType" class="t2" >
				<option value="PDF" <%=CommonUtil.nullToString(row.getJavaType()).equals("PDF")? "selected" : ""%>>PDF</option>
				<option value="EXCEL" <%=CommonUtil.nullToString(row.getJavaType()).equals("EXCEL")? "selected" : ""%>>EXCEL</option>
				<option value="CSV" <%=CommonUtil.nullToString(row.getJavaType()).equals("CSV")? "selected" : ""%>>CSV</option>
				<option value="HTM" <%=CommonUtil.nullToString(row.getJavaType()).equals("HTM")? "selected" : ""%>>HTM</option>
			</select>
		</td>
		<td nowrap>
			<% if (row.getJavaSource() != null) { %>
				<input type="button" value="Del.." class="button1" onClick="javascript:doSubmit('<%=InquiryJavaAction.ACTION_DEL_ATTACH%>', '<%=idx%>');">
			<% } else { %>
				<input type="button" value="Add.." class="button1" onClick="javascript:doSubmit('<%=InquiryJavaAction.ACTION_CHANGE_ATTACH%>', '<%=idx%>');">
			<% } %>
		</td>
	</tr>

	<% } // end if(row != null) %>

	<html:hidden property="idx" value="<%=row.getIdx()%>" />
	<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>

	</logic:iterate>

</table>

</html:form>
